import { defineStore } from 'pinia'
import { StoreType } from './type'
import type { IMenuEntity } from '@/types'
import request from '@/service'

export const useRouterStore = defineStore(StoreType.ROUTER_LIST, {
  state: () => {
    return {
      routerList: [] as IMenuEntity[]
    }
  },
  actions: {
    setRouterList(routerList: IMenuEntity[]) {
      this.routerList = routerList
    },

    /**
     * 获取菜单列表
     */
    async getRouterList() {
      return request.get<IMenuEntity[]>('/auth/menu')
    }
  }
})
